package com.blue.bluecode;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * 学习UI控件的Activity
 */
public class UiWidgetsActivity extends Activity implements View.OnClickListener {

    private Button
            btnTextView,
            btnButton,
            btnRadioButton,
            btnCheckBox,
            btnSwitch,
            btnToggleButton,
            btnImageView,
            btnImageButton,
            btnProgressBar,
            btnSeekBar,
            btnRatingBar,
            btnSpinner;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ui_widgets);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        initView();

    }

    private void initView() {
        btnTextView = (Button) findViewById(R.id.btnTextView);
        btnButton = (Button) findViewById(R.id.btnButton);
        btnRadioButton = (Button) findViewById(R.id.btnRadioButton);
        btnCheckBox = (Button) findViewById(R.id.btnCheckBox);
        btnSwitch = (Button) findViewById(R.id.btnSwitch);
        btnToggleButton = (Button) findViewById(R.id.btnToggleButton);
        btnImageView = (Button) findViewById(R.id.btnImageView);
        btnImageButton = (Button) findViewById(R.id.btnImageButton);
        btnProgressBar = (Button) findViewById(R.id.btnProgressBar);
        btnSeekBar = (Button) findViewById(R.id.btnSeekBar);
        btnRatingBar = (Button) findViewById(R.id.btnRatingBar);
        btnSpinner = (Button) findViewById(R.id.btnSpinner);

        btnTextView.setOnClickListener(this);
        btnButton.setOnClickListener(this);
        btnRadioButton.setOnClickListener(this);
        btnCheckBox.setOnClickListener(this);
        btnSwitch.setOnClickListener(this);
        btnToggleButton.setOnClickListener(this);
        btnImageView.setOnClickListener(this);
        btnImageButton.setOnClickListener(this);
        btnProgressBar.setOnClickListener(this);
        btnSeekBar.setOnClickListener(this);
        btnRatingBar.setOnClickListener(this);
        btnSpinner.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btnTextView:
                startActivity(new Intent(UiWidgetsActivity.this, TextViewActivity.class));
                break;
            case R.id.btnButton:
                startActivity(new Intent(UiWidgetsActivity.this, ButtonActivity.class));
                break;
            case R.id.btnRadioButton:
                startActivity(new Intent(UiWidgetsActivity.this, RadioButtonActivity.class));
                break;
            case R.id.btnCheckBox:
                startActivity(new Intent(UiWidgetsActivity.this, CheckBoxActivity.class));
                break;
            case R.id.btnSwitch:
                startActivity(new Intent(UiWidgetsActivity.this, SwitchActivity.class));
                break;
            case R.id.btnToggleButton:
                startActivity(new Intent(UiWidgetsActivity.this, ToggleButtonActivity.class));
                break;
            case R.id.btnImageView:
                startActivity(new Intent(UiWidgetsActivity.this, ImageViewActivity.class));
                break;
            case R.id.btnImageButton:
                startActivity(new Intent(UiWidgetsActivity.this, ImageButtonActivity.class));
                break;
            case R.id.btnProgressBar:
                startActivity(new Intent(UiWidgetsActivity.this, ProgressBarActivity.class));
                break;
            case R.id.btnSeekBar:
                startActivity(new Intent(UiWidgetsActivity.this, SeekBarActivity.class));
                break;
            case R.id.btnRatingBar:
                startActivity(new Intent(UiWidgetsActivity.this, RatingBarActivity.class));
                break;
            case R.id.btnSpinner:
                startActivity(new Intent(UiWidgetsActivity.this, SpinnerActivity.class));
                break;
        }
    }
}
